#include "Point2.h"

Point2::Point2(double x, double y) : x_(x), y_(y) {}

const bool Point2::operator==(const Point2& other) const{
    return (x_ == other.getX() && y_ == other.getY());
}

inline const bool Point2::operator!=(const Point2& other) const{
    return !(*this == other);
}

const Point2 Point2::operator+() const{
    Point2 temp = *this;
    return temp;
}

Point2& Point2::operator+=(const Vector2& v){
    x_ += v.getX();
    y_ += v.getY();
    return *this;
}
const Point2 Point2::operator+(const Vector2& v) const{
    Point2 temp(*this);
    temp += v;
    return temp;
}

Point2& Point2::operator-=(const Vector2& v){
    x_ -= v.getX();
    y_ -= v.getY();
    return *this;
}
const Point2 Point2::operator-(const Vector2& v) const{
    Point2 temp(*this);
    temp -= v;
    return temp;
}

const Vector2 Point2::operator-(const Point2& other) const{
    Vector2 v(x_ - other.getX(), y_ - other.getY());
    return v;
}

const double Point2::distance(const Point2& other) const{
    return sqrt(pow(x_ - other.getX(), 2) + pow(y_ - other.getY(), 2));
}

const double& Point2::getX() const{
    return x_;
}
const double& Point2::getY() const{
    return y_;
}


std::ostream& operator<<(std::ostream& os, const Point2& p){
    os << "Point2(" << p.x_ << ", " << p.y_ << ")";
    return os;
}

